"""用户地址"""
from common.base import AbstractBaseModel
from common.base import fields


class Address(AbstractBaseModel):
    user = fields.ForeignKeyField('models.User', on_delete=fields.CASCADE, related_name='addresses')
    title = fields.CharField(max_length=20, description='地址名称')
    receiver = fields.CharField(max_length=20, description='收货人')
    province = fields.ForeignKeyField('models.Area', on_delete=fields.RESTRICT,
                                      related_name='province_addresses', description='省')
    city = fields.ForeignKeyField('models.Area', on_delete=fields.RESTRICT, description='市',
                                  related_name='city_addresses')
    district = fields.ForeignKeyField('models.Area', on_delete=fields.RESTRICT, description='区',
                                      related_name='district_addresses')
    place = fields.CharField(max_length=50, description='地址')
    mobile = fields.CharField(max_length=11, description='手机号')
    tel = fields.CharField(max_length=20, description='固定电话', null=True, default='')
    email = fields.CharField(max_length=30, null=True, default='', description='电子邮箱')
    is_deleted = fields.BooleanField(default=False, description='逻辑删除')

    class Meta:
        table = 'tb_address'
        table_description = '收获地址'
        ordering = ('-modified',)
